<template>
	<view class="goods-list">
		<view class="goods-item" v-for="item in list" :key="item.id" @click="onItemClick(item.id)">
			<image :src="item.img_md" mode="widthFix"></image>
			<text class="title">{{item.name}}</text>
			<view class="price">
				¥<text>{{item.price}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "GoodsList",
		props: {
			list: {
				type: Array,
				default: () => {
					return []
				}
			}
		},
		methods:{
			onItemClick(id){
				this.$emit("click",id)
			}
		}
	}
</script>

<style lang="scss">
	.goods-list {
		// display: flex;
		// flex-wrap: wrap;
		margin: 0 10rpx;

		-moz-column-count: 2;
		-webkit-column-count: 2;
		column-count: 2;
		column-gap: 10rpx;

		.goods-item {
			-moz-page-break-inside: avoid;
			-webkit-column-break-inside: avoid;
			break-inside: avoid;
			border-radius: 10rpx;
			background-color: #fff;
			overflow: hidden;
			margin: 0 10rpx 20rpx 10rpx;
			padding-bottom: 10rpx;
			.title {
				color: $color-title;
				font-size: $size-title;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
				overflow: hidden;
				padding: 0 10rpx;
			}

			image {
				width: 100%;
			}

			.price {
				padding: 0 10rpx;
				color: red;
				font-size: $size-tips;

				text {
					font-size: $size-title;
				}
			}
		}
	}
</style>
